package com.project.livetv.fragment;

import android.os.Bundle;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.baoyz.widget.PullRefreshLayout;
import com.project.livetv.R;
import com.project.livetv.adapter.MyRecycleViewAdapter;

/**
 * Created by li on 2016/5/9.
 * 、、最新碎片
 */
public class LatestFragment extends BaseFragment {
    private RecyclerView mRecyclerView;
    private PullRefreshLayout mPullRefreshLayout;
    private MyRecycleViewAdapter myRecycleViewAdapter;
    private RecyclerView.LayoutManager manager;
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        View rootView=inflater.inflate(R.layout.latest_fragment_layout,container,false);
        mRecyclerView = (RecyclerView) rootView.findViewById(R.id.rcv_latestfragment_item);
        mPullRefreshLayout = (PullRefreshLayout) rootView.findViewById(R.id.prfl_latestFragnebt_refresh);
        iniData();
        setData();
        setListener();
        return rootView;


    }

    private void setListener() {
        mPullRefreshLayout.setOnRefreshListener(new PullRefreshLayout.OnRefreshListener() {
            @Override
            public void onRefresh() {
                mPullRefreshLayout.setRefreshing(false);
            }
        });


    }

    private void setData() {
        mRecyclerView.setLayoutManager(manager);
        mRecyclerView.setAdapter(myRecycleViewAdapter);
    }

    private void iniData() {
        manager = new GridLayoutManager(getContext(),3, LinearLayoutManager.VERTICAL,false);
        myRecycleViewAdapter = new MyRecycleViewAdapter(null,getContext());

    }


}
